package ysm.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import ysm.entity.Graduates;
import ysm.entity.Profession;
import ysm.entity.Registergraduates;
import ysm.mapper.ProfessionMapper;
import ysm.mapper.RegistergraduatesMapper;

@Service
public class RegistergraduatesService {
	
	@Autowired
	private RegistergraduatesMapper registergraduatesMapper;
	
	@Autowired
	private ProfessionMapper professionMapper;

	public void deleteByPrimaryKey(Integer id) {
		registergraduatesMapper.deleteByPrimaryKey(id);
	}

	public void insert(Registergraduates record) {
		registergraduatesMapper.insert(record);
	}

	public void insertSelective(Registergraduates record) {
		registergraduatesMapper.insertSelective(record);
	}

    public Registergraduates selectByPrimaryKey(Integer id) {
    	return registergraduatesMapper.selectByPrimaryKey(id);
    }

    public void updateByPrimaryKeySelective(Registergraduates record) {
    	registergraduatesMapper.updateByPrimaryKeySelective(record);
    }

    public void updateByPrimaryKey(Registergraduates record) {
    	registergraduatesMapper.updateByPrimaryKey(record);
    }
    
    public List loadAllRG() {
    	List list = registergraduatesMapper.loadAllRG();
		List result = new ArrayList();
		for(int i = 0; i < list.size(); i++) {
			Registergraduates registergraduates = (Registergraduates) list.get(i);
			Profession profession = professionMapper.selectByPrimaryKey(registergraduates.getProfession());
			registergraduates.setProfessionname(profession.getProfessionname());
			result.add(registergraduates);
		}
    	return result;
    }
    
    
    public Registergraduates selectRGByUid(Integer uid) {
    	return registergraduatesMapper.selectRGByUid(uid);
    }
}
